package com.songshuai.webapi.baseapi.controller;

import com.songshuai.webapi.baseapi.dto.response.SchoolResDto;
import com.songshuai.webapi.baseapi.pojo.QueryResponse;
import com.songshuai.webapi.baseapi.service.SchoolService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
@Api("学校")
@Slf4j
@RestController
@RequestMapping("/api/school/")
public class SchoolController {


    @Autowired
    private SchoolService schoolService;

    @ApiOperation(value = "根据学校名称获取学校信息")
    @GetMapping("getByName")
    public QueryResponse<List<SchoolResDto>> getByName(@RequestParam(value = "name",required = false) String name,
                                                @RequestParam(value = "limitNum",required = false)Integer limitNum){
        return QueryResponse.setResData(schoolService.getByName(name,limitNum==null ? 50:limitNum));
    }

    @ApiOperation(value = "根据校区id获取学校信息")
    @GetMapping("getByCampusId")
    public QueryResponse<List<SchoolResDto>> getByCampusId(@RequestParam("campusId") Integer campusId){
        return QueryResponse.setResData(schoolService.getByCampusId(campusId));
    }



}
